﻿SET QUOTED_IDENTIFIER ON
GO
SET ARITHABORT ON
GO
SET NUMERIC_ROUNDABORT OFF
GO
SET CONCAT_NULL_YIELDS_NULL ON
GO
SET ANSI_NULLS ON
GO
SET ANSI_PADDING ON
GO
SET ANSI_WARNINGS ON
GO

CREATE PROCEDURE [dbo].[bhp_NemoTranslateRemove] (
	@FieldId		INT,
	@Record		INT,
	@Language	NCHAR(5)
)
AS
BEGIN

	DELETE FROM 
		[bht_NemoTranslates] 
	WHERE
		record_id		= @Record
		AND field_id	= @FieldId
		AND lang_code	= @Language

	DECLARE
		@Sql					NVARCHAR(1000),
		@TabName		NVARCHAR(100)
		
	SELECT 
		@TabName = t2.name 
	FROM 
		n_Tree t1 
		INNER JOIN n_Tree t2 ON t1.parent = t2.id
	WHERE 
		t1.id = @FieldId
		
	SET @Sql = 'UPDATE ' + @TabName + ' SET mtime = GETDATE() WHERE idx = ' + CAST(@Record as NVARCHAR(100))
	EXEC sp_executesql @Sql

END